package com.czjtxy.extraTerm.controller.usermodule;

import com.czjtxy.extraTerm.entity.DO.Tuser;
import com.czjtxy.extraTerm.server.UserService;
import com.czjtxy.extraTerm.serverImpl.UserServiceImpl;
import com.czjtxy.extraTerm.util.Util;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.sql.SQLException;

/**
 * @program: staff-house
 * @author: MingYi
 * @create: 2021/07/02 08:43
 */
@WebServlet(name = "UserGetOneServlet", value = "/UserGetOneServlet")
public class UserGetOneServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        UserService userService = new UserServiceImpl();
        Tuser tuser = null;
        try {
            tuser = userService.getOne(Util.stringToInt(req.getParameter("uid")));
            req.setAttribute("tuser", tuser);
        } catch (SQLException | ClassNotFoundException throwables) {
            throwables.printStackTrace();
        }
        req.getRequestDispatcher("user/showUpdateUser.jsp").forward(req, resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        super.doPost(req, resp);
    }
}
